import Vue from 'vue'
import Vuex from 'vuex'
import axios from 'axios'
import VueAxios from 'vue-axios'
import { loginMutations, loginActions, loginState } from '../static/js/login'

Vue.prototype.$axiosx = axios

Vue.use(VueAxios, axios)

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    ...loginState,
    // 侧边导航栏状态
    menu: {
      menuState: false,
      menuWidth: '200px',
    },
    // 当前用户信息
    userInfo: {
      isLogged: false,
      employeeID: null,
      employeeTel: null,
      employeeLv: null,
      employeeName: null
    }
  },
  mutations: {
    ...loginMutations,
    menuToggle (state) {
      state.menu.menuState = !state.menu.menuState
      if (state.menu.menuWidth === '200px') {
        state.menu.menuWidth = '64px'
      } else {
        state.menu.menuWidth = '200px'
      }
    }
  },
  actions: {
    ...loginActions,
    menuToggle (context) {
      context.commit('menuToggle')
    }
  }
})
